package com.example.figurehecheng.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.figurehecheng.common.constant.MessageConstant;
import com.example.figurehecheng.common.context.BaseContext;
import com.example.figurehecheng.common.exception.AccountExist;
import com.example.figurehecheng.domain.dto.HotelDTO;
import com.example.figurehecheng.domain.entity.Hotel;
import com.example.figurehecheng.domain.entity.Merchant;
import com.example.figurehecheng.domain.entity.Tourtable;
import com.example.figurehecheng.domain.vo.TourtableVO;
import com.example.figurehecheng.mapper.HotelMapper;
import com.example.figurehecheng.service.IHotelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.figurehecheng.service.IMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 宇科工作室
 * @since 2024-10-18
 */
@Service
public class HotelServiceImpl extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {

    @Autowired
    private IMerchantService iMerchantService;

    @Override
    public void saveTour(HotelDTO housedto) {

        if (!ObjectUtil.isAllNotEmpty(housedto.getName(), housedto.getAddress(), housedto.getPhone())) {
            throw new AccountExist(MessageConstant.COUPON_NOT_NULL);
        }
        Hotel tour = BeanUtil.copyProperties(housedto, Hotel.class);
        tour.setShopId(BaseContext.getCurrentId().intValue());
        QueryWrapper<Merchant> merchantQueryWrapper = new QueryWrapper<Merchant>()
                .eq("id", BaseContext.getCurrentId());
        Merchant merchant = iMerchantService.getOne(merchantQueryWrapper);
        tour.setType(merchant.getRole());
        save(tour);

    }

    @Override
    public TourtableVO selectone() {
        return null;
    }

    @Override
    public void updatetour(HotelDTO housedto) {

    }

    @Override
    public void addvoideo(String urlname) {

    }

    @Override
    public String sevoideo() {
        return null;
    }
}
